package com.wudd.service.remote.user;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import com.wudd.common.bean.response.ResponseVO;

import feign.hystrix.FallbackFactory;

/**
 * 描述：feign远程调用异常捕获
 * @author 吴冬冬
 * @date 2018年11月7日 下午3:10:34  
 * @version V1.0
 */
@Component
public class UserClientFailFactory implements FallbackFactory<UserClient>{
	
	private static final Logger LOGGER = LoggerFactory.getLogger(UserClientFailFactory.class);
	
	@Override
	public UserClient create(final Throwable cause) {
		return new UserClient() {
			@Override
			public ResponseVO<String> getUserNameById(@RequestParam("userId") String userId) {
				LOGGER.info("获取用户名信息接口参数:userId={},异常:{}",userId,cause);
				return ResponseVO.error("远程调用调度接口异常");
			}
			
		};
	}

}
